package com.hzcx.app.simplechat.ui.home.dialog;

import android.content.Context;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.hzcx.app.simplechat.R;
import com.hzcx.app.simplechat.base.BaseDialog;
import com.hzcx.app.simplechat.util.UserInfoUtil;

import butterknife.BindView;

/**
 * 添加好友弹窗
 */
public class AddFriendDialog extends BaseDialog {

    @BindView(R.id.et_remark)
    EditText etRemark;
    @BindView(R.id.tv_cancel)
    TextView tvCancel;
    @BindView(R.id.tv_commit)
    TextView tvCommit;
    private OnAddFriendRemarkListener listener;

    public AddFriendDialog(@NonNull Context context, OnAddFriendRemarkListener listener) {
        super(context);
        this.listener = listener;
    }

    @Override
    public int getLayout() {
        return R.layout.dialog_add_friend;
    }

    @Override
    public void initPresenter() {

    }

    @Override
    public void initView() {

        tvCancel.setOnClickListener(view -> dismiss());

        tvCommit.setOnClickListener(view -> {
            if (listener != null) {
                listener.remark(etRemark.getText().toString());
            }
            dismiss();
        });

        etRemark.setText("我是" + UserInfoUtil.getUserNickName());
    }

    @Override
    public void initData() {

    }

    public interface OnAddFriendRemarkListener {
        void remark(String remark);
    }
}
